#include"touch.h"
#include"lcd.h"
#include"bmp.h"
#include"video.h"
#include"music.h"
#include"dir.h"
int main(int argc, char *argv[])
{

	LCD lcd;
	int x, y;
	
	// 初始化
	lcd_init(&lcd);
	Coordinate coor;
	TouchScreen ts;
	
	touchscreen_init(&ts);

	// 系统逻辑
	while(1)
	{
		printf("相册、音乐、视频\n");
		anybmp(0, 0, "res/menu.bmp", &lcd);	//刷新菜单界面
		ts_press(&coor, &ts);
		printf("(%d, %d)\n", coor.x, coor.y);
		
		if(coor.x>178 && coor.y>136 && coor.x<276 && coor.y<220)
		{
			anybmp(177, 136, "res/xcx.bmp", &lcd);
			ts_loosen(&coor, &ts);
			anybmp(177, 136, "res/xc.bmp", &lcd);
			
			if(coor.x>178 && coor.y>136 && coor.x<276 && coor.y<220)
			{
				printf("相册\n");
				photo(&lcd, &ts);
			}
		}
		else if(coor.x>360 && coor.y>136 && coor.x<449 && coor.y<225)
		{
			anybmp(361, 136, "res/yyx.bmp", &lcd);
			ts_loosen(&coor, &ts);
			anybmp(361, 136, "res/yy.bmp", &lcd);
			
			if(coor.x>360 && coor.y>136 && coor.x<449 && coor.y<225)
			{
				printf("音乐\n");
				music(&lcd,&ts);
			}
		}
		else if(coor.x>549 && coor.y>135 && coor.x<646 && coor.y<225)
		{
			anybmp(549, 134, "res/spx.bmp", &lcd);
			ts_loosen(&coor, &ts);
			anybmp(549, 135, "res/sp.bmp", &lcd);
			
			if(coor.x>549 && coor.y>135 && coor.x<646 && coor.y<225)
			{
				printf("视频\n");
				video(&lcd, &ts);
			}
		}
	}
	
	
	// 释放液晶屏资源
	lcd_uninit(&lcd);
	touchscreen_uninit(&ts);
	
	return 0;
}